$(function(){
	let username = sessionStorage.getItem("showusername");
	if (username) {
		let template = $("#login").clone(true);
		$(".user").html(username);
		template.appendTo($(".user"));
		$(".user").attr("href","#");
		$(".user").click(function(){
			$("#hover").css("display","block");
		})
	}
})

$(".banner").click(function(){
	$("#hover").css("display","none");
})
$("article").click(function(){
	$("#hover").css("display","none");
})
$(".qie").click(function(){
	location.href = "http://10.35.164.241:8080/sign.html"
})
$(".tui").click(function(){
	sessionStorage.removeItem("showusername");
	let template = $("#login").clone(true);
	$(".user").html("登录");
	template.appendTo($(".user"));
	$(".user").attr("href","#");
	$("#hover").css("display","none");
	sessionStorage.removeItem("state");
	window.location.reload();

})
$(".me").click(function(){
	location.href = "http://10.35.164.241:8080/order.html"
})

$(".car").click(function(){
	location.href = "http://10.35.164.241:8080/car.html"
})

$(".header-con-left h1").click(function(){
	location.href = "http://10.35.164.241:8080/index.html"
})

$(function(){
	$.ajax({
		url:"http://10.35.164.241:8080/selectCar",
		success:function(data){
			let carList = JSON.parse(data);
			if(sessionStorage.getItem("showusername")){
				let username = sessionStorage.getItem("showusername");
				$.ajax({
					url:`http://10.35.164.241:8080/selectUserCar?username=${username}`,
					success:function(data){
						let userList = (JSON.parse(data));
						$(".icon-car").html(userList.length);
					}
				})
			}
		}
	})
})